<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/5/24
 * Time: 16:33
 */

namespace Home\Service;


use Common\Common\Service;
use Home\Component\WechatComponent;
use Home\Exception\HomeException;
use Home\Request\wechat\AddWechatRequest;
use Home\Response\AddWechatResponse;

class AddWechatService implements Service
{
    public function run(AddWechatRequest $request = null)
    {
        $param = $request->getParam();
        $response = new AddWechatResponse();
        $component = new WechatComponent();
        try {
            $data = $component->addWechat($param);
            if (is_null($data) == true) {
                $response->setItIsNull();
            }
        } catch (HomeException $e) {
            throw new HomeException($e->getMessage(), $e->getCode());
        }
        return $response;
    }
}